/**
 * @Author:DarknessShadow
 * @description:模板子类
 * @date 2020/5/11 9:49
 */
public class StringDisplay extends AbstractDisplay {

    private String string;
    private int width;

    public StringDisplay(String string) {
        this.string = string;
        this.width = string.getBytes().length;
    }

    @Override
    public void open() {
        printLine();
    }
    private void printLine() {
        System.out.print("+");
        for (int i = 0; i < width; i++) {
            System.out.print("-");
        }
        System.out.println("+");
    }

    @Override
    public void print() {
        System.out.println("|" + string  +"|");
    }

    @Override
    public void close() {
        printLine();
    }
}
